package com.gcosc.hly.codejava.controller;

import com.gcosc.hly.codejava.entity.TopicResult;
import com.gcosc.hly.codejava.filter.AuthRoot;
import com.gcosc.hly.codejava.result.Result;
import com.gcosc.hly.codejava.service.TopicResultService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
@RequestMapping("/api/topicResult")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class TopicResultController {

    private final TopicResultService topicResultService;

    @PostMapping("/edit")
    @AuthRoot
    public Result edit(@RequestBody TopicResult topicResult){
        topicResultService.edit(topicResult);
        return Result.ok();
    }

    @PostMapping("/del/{ids}")
    @AuthRoot
    public Result del(@PathVariable String ids){
        topicResultService.removeBatchByIds(Arrays.asList(ids.split(",")));
        return Result.ok();
    }
}
